<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
    />
    <meta name="author" content="林镭特" />
    <title></title>

    <style></style>
  </head>
  <body>
    <!-- 微信朋友圈计时：1分钟内：刚刚发布；一小时内：多少分钟前；一天以内：多少小时前；超过一天：多少天前 -->
<P></P>
    <script>
      var nowTime = new Date();
      var targetTime = new Date("2020 1 2 09:20:46");
      var offsetTime = (nowTime.getTime() - targetTime.getTime()) / 1000;
      var minute = 60,
        hour = minute * 60,
        day = hour * 24;
      var days = Math.floor(offsetTime / day);
      var hours = Math.floor((offsetTime % day) / hour);
      var minutes = Math.floor(((offsetTime % day) % hour) / minute);
      var seconds = offsetTime % minute;

      var p=document.querySelector('p')
      if (offsetTime<minute) {
          p.innerHTML='刚刚发布'
      }else if (offsetTime<hour) {
          p.innerHTML=minutes+'分钟前'
      }else if (offsetTime<day) {
          p.innerHTML=hours+'小时前'
      }else {
          p.innerHTML=days+'天前'
      }

    </script>
  </body>
</html>
